﻿using Microsoft.EntityFrameworkCore;
using Sgr.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sgr.EntityFrameworkCore
{
    public class SqlserverDbContextConfigurator : IDbContextConfigurator
    {
        public void Configure(DbContextOptionsBuilder builder, string connectionString)
        {
            builder.UseSqlServer(connectionString,
                optionsBuilder =>
                {
                    optionsBuilder.UseQuerySplittingBehavior(QuerySplittingBehavior.SplitQuery);
                    optionsBuilder
                        .MinBatchSize(1)
                        .MaxBatchSize(1000);
                });
        }

        public bool IsSupported(DatabaseType dbType)
        {
            return dbType == DatabaseType.SqlServer;
        }
    }
}